function login(username: string): string {
    return "ok"
}
function login1<T>(username: T): T {
    return username
}

let res = login1("xiaohong")
console.log(res)

let res1 = login1(123)
console.log(res1)

function yyy<a, b>(a: a, b: b): [a, b] {
    return [a, b]
}

console.log(yyy("name", "xiaohong"))

function xxx<T extends string>(a: T): T {
    return a
}
let res2 = xxx("xiaohong")
type mmm = string | number
function ppp<T extends mmm>(a: T): T {
    return a
}
let res3 = ppp('ooo')
let res4 = ppp(33)

type mm = "small" | "big"
function ppp1<T extends mm>(a: T): T {
    return a
}
let res5 = ppp1('small')

type lll = { name: string, age: number }
let p1: lll = {
    name: "zs",
    age: 18
}

type fff = keyof lll // name|age
function ppp2<T extends fff>(a: T): T {
    return a
}
let res6 = ppp2('age')
function getValue(obj: any, xxx: any) {
    return obj[xxx]
}
let res7 = getValue({ name: "zs", age: 18 }, "age")
console.log(res7)
function getValue1(obj: { name: string, age: number }, xxx: string) {
    return obj[xxx]
}
let res8 = getValue1({ name: "zs", age: 18 }, "age")
console.log(res8)

function getValue2<T, K extends keyof T>(obj: T, xxx: K) {
    return obj[xxx]
}
